package com.itehima.Exception1;

import java.util.Scanner;

public class Prac01 {
    public static void main(String[] args) {

        //d得到心仪的女朋友，直到录入正确的信息为止

        //能够输入信息
        Scanner sc=new Scanner(System.in);
        GrirlFRINED gf=new GrirlFRINED();

        while (true) {
            try {
                System.out.println("请输入女朋友的名字");
                String name = sc.nextLine();
                gf.setName(name);
                System.out.println("请输入女朋友的年龄");
                int age = Integer.parseInt(sc.nextLine());
                gf.setAge(age);
                //如果得到正确的信息就跳出循环
                break;
            } catch (NumberFormatException e) {//对应parse
                e.printStackTrace();
            }catch(NameFormatException e)
            {
                e.printStackTrace();
            }catch (AgeOutofBoundsException e)
            {
                e.printStackTrace();
            }

        }
        System.out.println(gf);


    }
}
